<form name="editForm" role="form" novalidate (ngSubmit)="save()" #editForm="ngForm">

    <div class="modal-header">
        <h4 class="modal-title" id="myPostLabel">Create or edit a Post</h4>
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"
                (click)="clear()">&times;</button>
    </div>
    <div class="modal-body">
        <jhi-alert-error></jhi-alert-error>
        <div class="form-group" [hidden]="!post.id">
            <label for="id">ID</label>
            <input type="text" class="form-control" id="id" name="id"
                   [(ngModel)]="post.id" readonly />
        </div>
        <div class="form-group">
            <label class="form-control-label" for="field_title">Title</label>
            <input type="text" class="form-control" name="title" id="field_title"
                [(ngModel)]="post.title"
            required />
            <div [hidden]="!(editForm.controls.title?.dirty && editForm.controls.title?.invalid)">
                <small class="form-text text-danger"
                   [hidden]="!editForm.controls.title?.errors?.required">
                   This field is required.
                </small>
            </div>
        </div>
        <div class="form-group">
            <label class="form-control-label" for="field_content">Content</label>
            <input type="text" class="form-control" name="content" id="field_content"
                [(ngModel)]="post.content"
            required />
            <div [hidden]="!(editForm.controls.content?.dirty && editForm.controls.content?.invalid)">
                <small class="form-text text-danger"
                   [hidden]="!editForm.controls.content?.errors?.required">
                   This field is required.
                </small>
            </div>
        </div>
        <div class="form-group">
            <label class="form-control-label" for="field_createdOn">Created On</label>
            <div class="input-group">
                <input id="field_createdOn" type="text" class="form-control" name="createdOn" ngbDatepicker  #createdOnDp="ngbDatepicker" [(ngModel)]="post.createdOn"
                />
                <span class="input-group-btn">
                    <button type="button" class="btn btn-default" (click)="createdOnDp.toggle()"><i class="fa fa-calendar"></i></button>
                </span>
            </div>
        </div>

    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal" (click)="clear()">
            <span class="fa fa-ban"></span>&nbsp;<span>Cancel</span>
        </button>
        <button type="submit" [disabled]="editForm.form.invalid || isSaving" class="btn btn-primary">
            <span class="fa fa-save"></span>&nbsp;<span>Save</span>
        </button>
    </div>
</form>
